
/**
 * GW165-接口-选择制表岗位后验证是否为最高管理者，判断审批权限是否异常
 */
var gw165 = function(param) {
	let _that = param._that;
	_that.om.request('posBusiAuth/GW165', 
			{
				posId: param.posId,
				code :param.busCode
			},
		)
		.then(res => {
			if (res.succeed && res.value.tip) {
				one_button(d.value.tip, function() {
					_that.formdata.zposIndex = -1;
					_that.formdata.zposId = "";
					_that.formdata.zposName = "";
					if(param.fail){
						param.fail()
					}	
				})
			}else{
				if(param.success){
					param.success()
				}
			}
		});
}

var loadZpos = function(_that, afterZposFunc, emptyTip) {
	if (!_that.busCode) {
		_that.om.toast('busCode is null')
		return
	}
	_that.om
		.request(
			'wxPosBusiAuth/isnewList', {
				code: _that.busCode
			},
			'post'
		)
		.then(res => {
			//if (res instanceof Array) {
			if(Object.prototype.toString.call(res)==='[object Array]'){
				_that.zposList = res;
				if (res.length) {
					if (_that.formdata) {
						_that.formdata.zposId = res[0].id;
						_that.formdata.zposName = res[0].posname;
					}
				} else {
					if (emptyTip) {
						_that.om.toast(emptyTip, 3000)
					}
				}
				if (afterZposFunc) {
					if (typeof(afterZposFunc) === 'string') {
						if (_that[afterZposFunc]) {
							_that[afterZposFunc]();
						} else {
							eval(afterZposFunc + "()");
						}
					} else if (typeof(afterZposFunc) === 'function') {
						afterZposFunc();
					}
				}
			} else {
				_that.om.toast('系统异常');
			}
		});
}

export {
	gw165,
	loadZpos
}